package DomainLayer;

import Annotations.AttributeNameAnnotation;
import Annotations.ValueObjectNameAnnotation;

@ValueObjectNameAnnotation(Name = "UserState")
public class UserStateValueObject extends AbstractValueObject {
	@AttributeNameAnnotation(Name = "sessionId", isAggregator = false)
	private final String sessionId;

	@AttributeNameAnnotation(Name = "IsBanned", isAggregator = false)
	private final boolean isBanned;

	@AttributeNameAnnotation(Name = "LastIP", isAggregator = false)
	private final String lastIP;

	public String getSessionId() {
		return sessionId;
	}

	public boolean isBanned() {
		return isBanned;
	}

	public String getLastIP() {
		return lastIP;
	}

	public UserStateValueObject() {
		super();
		isBanned = false;
		sessionId = null;
		lastIP = null;
	}

	// Use this cotr for create or change value object. Instance of this class
	// MUST be immutable.
	public UserStateValueObject(UserStateValueObject currentState,
			Object... changes) {
		super(currentState, changes[0]);
		isBanned = (changes[1] != null ? ((Boolean) changes[1]).booleanValue()
				: currentState.isBanned);
		sessionId = (changes[2] != null ? (String) changes[2]
				: currentState.sessionId);
		lastIP = (changes[3] != null ? ((String) changes[3])
				: currentState.lastIP);
	}
}
